package com.example.d1216;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import org.litepal.LitePal;

import java.util.List;

public class ChaXuActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView cahxubianhao;
    private TextView chikrxingmin;
    private TextView yikayue;
    private Button chaxuM;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cha_xu);
        initView();
        initData();
    }

    private void initData() {
        //接收Intent传入参数
        Intent intent = getIntent();
        String sign = intent.getStringExtra("signX");
        //数据库查询次参数相关信息
        List<User> list = LitePal.where("kahao=?",sign).find(User.class);
        //相关信息显示到Ui
        cahxubianhao.setText(list.get(0).getKahao());
        chikrxingmin.setText(list.get(0).getKaming());
        yikayue.setText(list.get(0).getKayuer()+"元");
    }

    private void initView() {
        cahxubianhao = (TextView) findViewById(R.id.cahxubianhao);
        chikrxingmin = (TextView) findViewById(R.id.chikrxingmin);
        yikayue = (TextView) findViewById(R.id.yikayue);
        chaxuM = (Button) findViewById(R.id.chaxuM);
        chaxuM.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.chaxuM:
                startActivity(new Intent(this,MainActivity.class));
                break;
        }
    }
}
